<?php
require_once 'connectDb.php';
//we're fetching the event associated with the actual current session user
$id = addslashes($_SESSION['fb_id']);
$query = "SELECT * FROM event WHERE fb_id_author = '" . $id . "' AND status  = 'A' ORDER BY creation_date  LIMIT 0,1 ";
$result = mysql_query($query);
if (!$result) {
  $evento_actual = null;
} else {
  $evento_actual = mysql_fetch_row($result);

  $qGuests = 'SELECT g.* FROM event e, guest g, event_has_guest eg WHERE e.id = ' . $evento_actual[0] . ' and g.id = eg.guest_id and e.id = eg.event_id';
 
  $resultGuests = null;
  $resultGuests = mysql_query($query);
  if (!$resultGuests) {
    $guests = null;
  } else {
    $guests = mysql_fetch_row($resultGuests);
  }
    
}


#print_r($evento_actual);
?>
<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width" />
    <title>Oni - Evento Actual </title>
    <link rel="stylesheet" type="text/css" href="css/normalize.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" type="text/css" href="css/jquery.fancybox.css" />
    <link rel="stylesheet" type="text/css" href="css/home/home.css" />
    <link rel="stylesheet" type="text/css" href="css/home/nuevo_actual.css" />

    <script src="js/modernizr.js"></script>
  </head>
  <body>
  <header></header>
  <div id="main_wrapper">


    <?php require_once 'header.php'; ?>

    <div id="main_content">

      <div id="panel_overlay">

        <div id="flag_top_head">
          <p class="title_event"><?php echo $evento_actual[3]; ?></p>
          <p class="date_event"><?php echo $evento_actual[5]; # convertir a  15 de Agosto de 2012  ?></p>
          <p class="meta_quantity">$<?php echo $evento_actual[8]; ?></p>
        </div>
        <div id="event_counter">
          <p class="dia_count">02</p>
          <p class="hr_count">14</p>
          <p class="min_count">27</p>
        </div>
        <div id="results_count">
          <p class="red_leter_count left"><?php echo $evento_actual[7]; ?></p>
          <p class="red_leter_count center"><?php echo floor($evento_actual[7] / $cost_oni); ?></p>
          <p class="red_leter_count right"><?php echo floor($evento_actual[7] / $cost_oni / $consumo_oni); ?></p>

        </div>


      </div>
      <p id="desc_down">Con tu ayuda podemos llegar a la meta</p>
      <a href="javascript:;" id="btn_donar"></a>
      <p id="desc_paypal">¿Cómo donar en Paypal?</p>

      <div id="panel_invitados">
        <div id="top_flag"></div>
        <div id="friends_panel">
          <?php
          if ($guests != null) {
           
            foreach ($guests as $guest) {
 ?>
              <div class="fb_friend_display"><a href=""><img src="https://graph.facebook.com/<?php echo $guest[1] ?>/picture" /></a><p class="fb_profile_name"><?php echo $guest[2] ?></p></div>
          <?php
            }
          } else {
          ?>
            <div class="fb_friend_display"><p class="fb_profile_name">Aún no hay invitados</p></div>
          <?php
          }
          ?>

        </div>

      </div>

    </div><!-- END #main_content  -->


  </div> <!-- END #main_wrapper  -->

  <div id="lightbox_wrap" href="javascript:;" style="display: none">
    <div id="lightbox_container">


      <a href="javascript:;" id="btn_add_lightbox"></a>
      <a href="javascript:;" id="btn_close_lightbox"></a>
    </div>

  </div>

  <footer></footer>
  <script src="js/jquery-1.7.2.min.js"></script>
  <script src="js/jquery.fancybox.js"></script>
  <script src="js/home/home.js"></script>
  <script src="js/home/nuevo_evento.js"></script>
</body>
</html>
